import UtilFuncs from "../../common/tools/utilfuncs";
var funcs = UtilFuncs.UtilFuncs;
import {CoordTRFUtil}  from "../../common/tools/coordtool";

var EclipseArcUtil = {}

EclipseArcUtil.eclipseArcTo = function (trfFunc,cntPt, xradius, yradius, stRad, endRad, 
    anticlockwise, map, mapInfo,starFlag, transformInfo) {
    const spliceCount = 200;
    let radgap = Math.abs(endRad - stRad) / spliceCount;
    let x = cntPt.x + xradius * Math.cos(stRad);
    let y = cntPt.y + yradius * Math.sin(stRad);
    let spt = trfFunc({ x, y }, mapInfo, transformInfo);
    if (starFlag)
        map.moveTo(spt.x, spt.y);
    else
        map.lineTo(spt.x, spt.y);

    if (!anticlockwise){
        //顺时针
        for (let i = 1; i < spliceCount; i++) {
            let tmpRad = stRad - i * radgap;
            x = cntPt.x + xradius * Math.cos(tmpRad);
            y = cntPt.y + yradius * Math.sin(tmpRad);
            spt = trfFunc({ x, y }, mapInfo, transformInfo);
            map.lineTo(spt.x, spt.y);
        }
    }
    else{
        //逆时针
        for (let i = 1; i < spliceCount; i++) {
            let tmpRad = stRad + i * radgap;
            x = cntPt.x + xradius * Math.cos(tmpRad);
            y = cntPt.y + yradius * Math.sin(tmpRad);
            spt = trfFunc({ x, y }, mapInfo, transformInfo);
            map.lineTo(spt.x, spt.y);
        }
    
    }
    
}


export { EclipseArcUtil }
